/**
 * Created by baiguiren on 1/16/17.
 */

let async = require('async');

let test_arr = [1, 2, 3, 4, 5];

async.transform(test_arr, (acc, item, index, callback) => {
  process.nextTick(() => {
    acc.push(item * 2);
    callback();
  });
}, (err, results) => {
  console.log(err ? err : results);
});

async.transform({a: 1, b: 2, c: 3}, (obj, value, key, callback) => {
  process.nextTick(() => {
    obj[key] = value * 2;
    callback();
  });
}, (err, results) => {
  console.log(err ? err : results);
});